package com.rw.admin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rw.common.mapper.CarInfoMapper;
import com.rw.common.pojo.CarInfo;
import com.rw.admin.service.CarInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarInfoServiceImpl implements CarInfoService {
    @Autowired
    private CarInfoMapper carInfoMapper;

    @Override
    public PageInfo getDataByPage(Integer pageNum, Integer limit) {
        PageHelper.startPage(pageNum,limit);
        List<CarInfo> list = carInfoMapper.selectAll();
        //这个值应该是缓存或者配置文件中读取的
        String baseUrl = "http://localhost:8888/";
        for (CarInfo item:list){
            item.setPhoto(baseUrl+item.getPhoto());
        }
        PageInfo page = new PageInfo(list);
        return page;
    }
}
